<template>
    <vxe-modal v-model="isShowPopover"
               ref="minxVxeModal"
               title="入库产品详情"
               :mask="false"
               width="900"
               :lock-view="false"
               dblclickZoom
               :z-index="600"
               :resize='true'
               :remember='true'
               class="wms-in-detail-modal"
               id="wmsInDetail"
               :storage="true">
        <div class="text-r pl-15 pr-15 mb-10 mt-10">
            <a-button size="small" type="primary" icon="arrow-down" @click="exportWmsInDetail">导出</a-button>
        </div>
        <vxe-grid
                ref="addWmsInTable"
                border
                size="mini"
                resizable
                auto-resize
                highlight-hover-row
                highlight-current-row
                :height="400"
                export-config
                :loading="loading"
                :columns="columns"
                :data="tableData">
        </vxe-grid>
    </vxe-modal>
</template>

<script>
    export default {
        data () {
            return {
                isShowPopover: false,
                loading: false,
                tableData: [],
                columns: [
                    { type: 'seq', fixed: 'left', title: '序号', width: 60, noColumnsSet: true, resizable: false },
                    { title: '分类名称', minWidth: 150, align: 'center', field: 'categoryName' },
                    { title: '产品名称', minWidth: 150, align: 'center', field: 'productName' },
                    { title: '入库数', minWidth: 120, align: 'center', field: 'intoCount' },
                    { title: '单价', minWidth: 120, align: 'center', field: 'intoPrice' },
                    { title: '金额', minWidth: 120, align: 'center', field: 'amount' },
                    { title: '属性值', minWidth: 120, align: 'center', field: 'param' },
                    { title: '备注', minWidth: 120, align: 'center', field: 'remark' },
                ],
            };
        },
        methods: {
            show (id) {
                this.getData(id);
                this.isShowPopover = true;
            },
            close () {
                this.loading = false;
                this.tableData = [];
                this.isShowPopover = false;
            },
            getData (id) {
                this.loading = true;
                this.$api.wms.warehouseindetaillist({
                    pageNum: 1,
                    pageSize: 999,
                    warehouseInId: id
                }).then(res => {
                    this.loading = false;
                    this.tableData = res && res.data && res.data.records || [];
                }).catch(err => {
                    this.loading = false;
                    this.$message.error(err.errorMsg);
                });
            },
            exportWmsInDetail () {
                this.$refs.addWmsInTable.exportData({ type: 'csv' });
            }
        },
    };
</script>

<style>
    .wms-in-detail-modal .vxe-modal--body{
        padding: 0!important;
    }
</style>
